﻿@using System.Globalization
@{
    var currentCulture = WorkContext.CurrentCulture;
    var supportedCultures = (IList<string>)Model.SupportedCultures;
}

<div id="culture-selection">
    <select>
        @foreach (var supportedCulture in supportedCultures) {
            var cultureInfo = CultureInfo.GetCultureInfo(supportedCulture);
            var url = Url.Action("ChangeCulture", "AdminCultureSelector", new { area = "Orchard.Localization", culture = supportedCulture, returnUrl = Html.ViewContext.HttpContext.Request.RawUrl });

            <option @if (supportedCulture.Equals(currentCulture)) { <text> selected="selected" </text>  } value="@url">
                @cultureInfo.DisplayName&#x200E;
            </option>
        }
    </select>
</div>
@using (Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
   (function ($) {
       $("#culture-selection").change(function (e) {
           window.location = $("#culture-selection > select > option:selected")[0].value;
       });
   })(jQuery);
//]]>
</script>
}